//
//  WmcTeamCloudCategriesAlbumVM.swift
//  YPWatermarkCamera
//
//  Created by yupao_ios_macmini06 on 2022/9/16.
//

import Foundation

class WmcTeamCloudCategriesAlbumVM: WmcBaseVM {
    /// 团队相册
    var teamAblum: WmcMediaTeamAlbumModel?

    /// 界面显示的列表数据
    private(set) var dataSource: [WmcMediaAlbumModel] = []

    /// 团队相册分类获取
    /// - Parameters:
    ///   - completion: completion description
    ///   - failure: failure description
    func fetchList(completion: @escaping ([WmcMediaAlbumModel]) -> Void, failure: @escaping (Error?) -> Void) {
        guard let albumId = teamAblum?.albumId, let teamId = teamAblum?.teamId else { return }

        WmcMediaTeamAlbumAPI.fetchClassifyAlbumList(albumId: "\(albumId)", teamId: teamId).subscribe(onNext: { [weak self] list in
            guard let weakSelf = self else { return }
            weakSelf.dataSource = list
            completion(list)
        }, onError: { error in
            failure(error)
        }).disposed(by: rx.disposeBag)
    }
}
